package scoutobahn.xml;

import java.util.Map;

/**
 * An OsmNode. In the OSM Terminology a node is a point on the map.
 * @author mark
 *
 */
public class OsmNode extends OsmItem {

    private final double latitude;
    private final double longitude;
    /**
     * Constructs a new OsmNode with the given id, longitude and latitude.
     * @param newId The id of the node
     * @param tags The tags of this node
     * @param nlongitude Longitude
     * @param nlatitude Latitude
     */
    public OsmNode(final long newId,
            final Map<String, String> tags,
            final double nlongitude,
            final double nlatitude) {
        super(newId, tags);
        this.latitude = nlatitude;
        this.longitude = nlongitude;
    }
    /**
     * The latitude of the node.
     * @return Latitude
     */
    public double getLatitude() {
        return latitude;
    }
    /**
     * The longitude of the node.
     * @return Longitude
     */
    public double getLongitude() {
        return longitude;
    }
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        long temp;
        temp = Double.doubleToLongBits(latitude);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(longitude);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        return result;
    }
    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        OsmNode other = (OsmNode) obj;
        if (Double.doubleToLongBits(latitude) != Double
                .doubleToLongBits(other.latitude)) {
            return false;
        }
        if (Double.doubleToLongBits(longitude) != Double
                .doubleToLongBits(other.longitude)) {
            return false;
        }
        return true;
    }

}
